load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@buildifier_prebuilt//:rules.bzl", "buildifier")
load("@gazelle//:def.bzl", "gazelle", "gazelle_binary")
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("//bazeldnf:defs.bzl", "bazeldnf", "rpmtree", "tar2files")

gazelle_binary(
    name = "gazelle_binary",
    languages = [
        "@bazel_skylib_gazelle_plugin//bzl",
        "@gazelle//language/go",
        "@gazelle//language/proto",
    ],
)

# gazelle:exclude .bazelbsp
# gazelle:prefix github.com/rmohr/bazeldnf
# gazelle:resolve go github.com/bazelbuild/buildtools/build @com_github_bazelbuild_buildtools//build:go_default_library
# gazelle:resolve go github.com/bazelbuild/buildtools/edit @com_github_bazelbuild_buildtools//edit:go_default_library
gazelle(
    name = "gazelle",
    args = [
        "-exclude",
        "pkg/bazel/testdata",
    ],
    gazelle = "//:gazelle_binary",
)

gazelle(
    name = "gazelle.check",
    args = [
        "-exclude",
        "pkg/bazel/testdata",
    ],
    gazelle = "//:gazelle_binary",
    mode = "diff",
)

buildifier(
    name = "buildifier",
)

buildifier(
    name = "buildifier.check",
    diff_command = "diff -u",
    exclude_patterns = [
        "./.git/*",
        "./**/testdata/*",
    ],
    lint_mode = "warn",
    mode = "diff",
)

bazeldnf(
    name = "bazeldnf",
)

rpmtree(
    name = "something",
    rpms = [
        "@bazeldnf_internal_libvirt-libs//rpm",
        "@bazeldnf_internal_libvirt-devel//rpm",
    ],
)

tar2files(
    name = "something_libs",
    files = {
        "/usr/lib64": [
            "libvirt.so.0",
            "libvirt.so.0.11000.0",
        ],
    },
    tar = ":something",
    visibility = ["//visibility:public"],
)

pkg_tar(
    name = "whatever",
    deps = [":something"],
)

cc_library(
    name = "bar",
    srcs = ["//:something_libs/usr/lib64"],
)

bzl_library(
    name = "def",
    srcs = ["def.bzl"],
    visibility = ["//visibility:public"],
    deps = ["@bazeldnf//bazeldnf:defs"],
)

bzl_library(
    name = "deps",
    srcs = ["deps.bzl"],
    visibility = ["//visibility:public"],
    deps = [
        "@bazeldnf//bazeldnf:defs",
        "@bazeldnf//bazeldnf:deps",
    ],
)
